home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / TEST / MINTBUG3.M < prev    next >
Encoding:
Text File  |  1992-02-19  |  2.6 KB  |  95 lines

  1. MODULE MiNTBug3;
  2. (*$C-,N+,R-,L-*)
  3.  
  4. (*
  5.  * this program shows, that the SP of a new process points into its
  6.  * base page (bp + $E0) where it corrupts the cmd line.
  7.  * if the program run correctly, the exit code is 1, otherwise -1
  8.  *
  9.  * NOTE: link with no additional startup code!
  10.  *)
  11.  
  12. FROM SYSTEM IMPORT ASSEMBLER;
  13.  
  14. BEGIN
  15.   ASSEMBLER
  16.         ; create a new base page
  17.         CLR.L   -(A7)           ; env
  18.         PEA     null(PC)        ; com
  19.         CLR.L   -(A7)           ; path
  20.         MOVE.W  #5,-(A7)        ; mode
  21.         MOVE    #$4B,-(A7)
  22.         TRAP    #1
  23.         ADDA.W  #16,A7
  24.         
  25.         ; reduce TPA to size of base page only:
  26.         ; Mshrink (base page, 256)
  27.         MOVE.L  #256,-(A7)
  28.         MOVE.L  D0,-(A7)
  29.         CLR.W   -(A7)
  30.         MOVE    #$4A,-(A7)
  31.         TRAP    #1
  32.         MOVE.L  4(A7),A0        ; A0: base page addr
  33.         ADDA.W  #12,A7
  34.         
  35.         ; do base page settings
  36.         lea     (a0),a2
  37.         lea     low_sp(pc),a1
  38.         move.l  a1,(a2)+        ; p_lowtpa:= low_sp;
  39.         lea     top_sp(pc),a1
  40.         move.l  a1,(a2)+        ; p_hitpa := top_sp;
  41.         lea     proc1(pc),a1
  42.         move.l  a1,(a2)+        ; p_tbase := proc1;
  43.         clr.l   (a2)+           ; p_tlen  := 0L;
  44.         clr.l   (a2)+           ; p_dbase := 0L;
  45.         clr.l   (a2)+           ; p_dlen  := 0L;
  46.         clr.l   (a2)+           ; p_bbase := 0L;
  47.         clr.l   (a2)+           ; p_blen  := 0L;
  48.         
  49.         ; call process (proc1)
  50.         CLR.L   -(A7)           ; env
  51.         MOVE.L  A0,-(A7)        ; com
  52.         CLR.L   -(A7)           ; path
  53.         MOVE.W  #4,-(A7)        ; mode
  54.         MOVE    #$4B,-(A7)
  55.         TRAP    #1
  56.         ADDA.W  #16,A7
  57.         
  58.         ; do Pterm(D0)
  59.         move    D0,-(a7)
  60.         move    #$4c,-(a7)
  61.         trap    #1
  62.  
  63.         ; here's the sub-process' code:
  64.  
  65. proc1:  ; ERROR! A7 points into the base page, but it should point into TPA!
  66.         move.l  4(a7),a5        ; load ptr to our base page
  67.         ;illegal                 ;  call resident debugger (e.g. templemon)
  68.         
  69.         ; verify a7 and set appropriate exit code
  70.         lea     low_sp(pc),a0
  71.         cmpa.l  a0,a7
  72.         bls     error
  73.         lea     top_sp(pc),a0
  74.         cmpa.l  a0,a7
  75.         bhi     error
  76.         
  77.         ; OK: do Pterm(1)
  78.         move    #1,-(a7)
  79.         move    #$4c,-(a7)
  80.         trap    #1
  81.         
  82. error:  ; do Pterm(-1)
  83.         move    #-1,-(a7)
  84.         move    #$4c,-(a7)
  85.         trap    #1
  86.  
  87.         ; stack area (defined as TPA):
  88. low_sp: ds      100     ; 100 bytes
  89. top_sp:
  90.  
  91. null:   DC.W    0
  92.  
  93.   END
  94. END MiNTBug3.
  95.